<template>
<div>
    <el-dialog title="系统登录" 
    :visible.sync="dialogFormVisible"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :show-close="false">
  <el-form >
      <el-input id="name"  v-model="loginForm.loginId" placeholder="请输入帐号">  
            <template slot="prepend">帐号</template>  
        </el-input>  
        <el-input id="password" v-model="loginForm.loginPwd" type="password" placeholder="请输入密码">  
            <template slot="prepend">密码</template>  
        </el-input>  
  </el-form>
  <div slot="footer" class="dialog-footer">
        <el-button id="login" @click="doLogin" style="width:100%" type="primary">登录</el-button>  
  </div>
</el-dialog>

 </div>
</template>

 <script type="text/javascript">  
 export default{  
        data () {
            return {  
            dialogFormVisible:true,
            loginForm:{
                loginId : '',  
                loginPwd : ''
                }
            }  
        },  
        methods : {  
           doLogin(){
            this.$store.dispatch("userLogin", this.loginForm)
                .then(res => {  
                    //Promise对象调用了resolve
                    this.$router.push('/index');
                })
                .catch(error => {
                     //Promise对象调用了reject
                    console.info(error)
                    this.$message({showClose: true,message: '登入失败！',type: 'error'});
                });
           }
        }  
    } 
</script>  